home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / ib.510 < prev    next >
Text File  |  1992-02-06  |  3KB  |  27 lines

  1. Interface Builder nib module file's owner
  2.  
  3. Q:  What is the "file owner's" of a .nib file?
  4.  
  5. A: The interface file's owner is an object that's external to the interface file and that's the conduit between objects in the interface file and the other objects in your application. 
  6.  
  7. Each interface file has one, and only one, owner.  For small applications, the owner is generally NXApp, the application object itself, although it can be an object of any class.  The owner is the only external object that may be the explicit target of action messages from Controls within the interface file.  The owner may also have outlets that will be initialized at run time to the id's of objects within the interface file. 
  8.  
  9. A nib file is actually an archived collection of objects (windows, panels, controls, etc) that you designed in Interface Builder.  When that file is unarchived at runtime and those objects are loaded, some object needs to "own" them.  For example, the main menu is loaded and owned by NXApp.  When you only have one nib file, actually all objects are loaded and owned by NXApp.  When you have multiple nib files (like /NextDeveloper/Examples/Draw), you explicitly set the owner of each file.  The owner is like the "shepherd" of the objects in its file.  The owner sends messages to its objects (makeKeyAndOrderFront: to panels, for example) and it also can receive messages from its object (a button that sent its target method "quit:" to the file's owner, for example).  As usual, you make these connections in Interface Builder. 
  10.  
  11. The file's owner is the only link between those objects and objects elsewhere in the other nib files of this application.  For example, you could create an info panel in a separate nib module, and have a custom object Controller which owns that nib file.  Your main menu item "Info..." is in the main nib file and doesn't know about the info panel because it is in a separate nib file.  However, the main menu can send a message to the Controller object, which will, in turn, send a message to the info panel to tell it to display itself.
  12.  
  13. Why would you choose to use separate nib files?  At launch time, your entire nib file (all the panels, menus, buttons, whatnot) is unarchived.  This may inefficiently squander your precious time and memory.  If you have a panel that is sparsely used, you may instead want to place it in a separate nib module and load it when, and if, it is needed.
  14.  
  15. Interface Builder modules also allow you to create custom panels, windows, and objects that are reusable.  You could place the panel in a nib module and design a custom object that will control and own it, and then by instantiating that object and reusing the nib module file, you can add that panel and its functionality to any application you create.
  16.  
  17. Look at the two-nib-file example of the Text Editor in the IB tutorial (Chapter 8 of the NeXTstep Concepts manual) as a guide, and for a more advanced use, see /NextDeveloper/Examples/Draw.
  18.  
  19. See also NextAnswer ib.511.
  20.  
  21. QA510    
  22.  
  23. Valid for 1.0
  24. Valid for 2.0
  25.  
  26.  
  27.